<?php
/**
 * Created by JetBrains PhpStorm.
 * User: CAIXUDONG
 * Date: 11-6-20
 * Time: 下午4:17
 */
 
class BaoBeiSourceController extends Controller{

    public function index(){

        $curr_page = (int)$this->input()->post('pageNum',1);
        $per_page  = (int)$this->input()->post('numPerPage',30);
        $zh_name = $this->input()->post('zh_name');
        $en_name = $this->input()->post('en_name');
        $is_show = $this->input()->post('is_show');
        $filter = array();

        if($zh_name){
            $filter['zh_name'] = $zh_name;
        }

        if($en_name){
            $en_name['en_name'] = $en_name;
        }

        if($is_show || $is_show !=null){
            $filter['is_show'] = $is_show;
        }

        $list = Model::getInstance('baobeisource')->getBaoBeiSourceList($curr_page,$per_page,$filter);
        $data = array(
            'list'=>$list,
        );
        Template::show('baobei/baobeisource.php',$data);

    }

    public function add(){

        Template::show('baobei/add_baobeisource.php');
    }

    public function edit(){

        $id = (int)$this->input()->get('id');

        $source_info = Model::getInstance('baobeisource')->get($id);

        $data = array(
            'source_info'=>$source_info
        );

        Template::show('baobei/edit_baobeisource.php',$data);
    }
}